#import "GameManager.h"
#import "PlayScene.h"

@implementation GameManager
@synthesize gameState;
@synthesize currentScene;
@synthesize currentLevel;


static GameManager *sharedGameManager = nil;

+(GameManager *) sharedGameManager
{

    if(sharedGameManager == nil)
    {
        sharedGameManager = [[GameManager alloc] init];
    }
    
    return sharedGameManager;
}

-(id) init
{
    if( (self = [super init]) )
    {
        self.currentLevel = -1;
        [self setGameState:kGAME_STATE_NIL];
    }
    
    return self;
}

-(void) dealloc
{
    [super dealloc];
}

#pragma mark - Generic Scene Action
-(void) replaceScene:(EGameScene)kGameScene
{
/*
    //Replace by Now Loading, to reduce Memory Consumption
    [[CCDirector sharedDirector] replaceScene:[LoadingScene node]];
    CCLOG(@"Replaced Now Loading Scene");
	
    switch (kGameScene) {
        case kGAME_SCENE_MAIN_MENU:
            [[CCDirector sharedDirector] replaceScene:[MainMenuScene node]];
            CCLOG(@"Replaced MainMenuScene");
            break;
        case kGAME_SCENE_OPTION:
            [[CCDirector sharedDirector] replaceScene:[OptionScene node]];
            CCLOG(@"Replaced OptionScene");
            break;
		case kGAME_SCENE_MODE_SELECT:
			[[CCDirector sharedDirector] replaceScene:[ModeSelectScene node]];
			CCLOG(@"Replaced ModeSelectScene");
			break;
        case kGAME_SCENE_LEVEL_SELECT:
            [[CCDirector sharedDirector] replaceScene:[LevelSelectScene node]];
            CCLOG(@"Replaced LevelSelectScene");
            break;
        default:
            CCLOG(@"Replacing Unknown Scene");
            break;
    }

    [self setCurrentScene:kGameScene];
*/
}

-(void) pushScene:(EGameScene)kGameScene
{
/*
    switch (kGameScene) {
        case kGAME_SCENE_MAIN_MENU:
            [[CCDirector sharedDirector] pushScene:[MainMenuScene node]];
            CCLOG(@"Pushed MainMenuScene");
            break;
        case kGAME_SCENE_OPTION:
            [[CCDirector sharedDirector] pushScene:[OptionScene node]];
            CCLOG(@"Pushed OptionScene");
            break;
        case kGAME_SCENE_LEVEL_SELECT:
            [[CCDirector sharedDirector] pushScene:[LevelSelectScene node]];
            CCLOG(@"Pushed LevelSelectScene");
            break;
        case kGAME_SCENE_LEVEL_1:
            [[CCDirector sharedDirector] pushScene:[Level1Scene node]];
            CCLOG(@"Pushed Level1Scene");
            break;
        default:
            CCLOG(@"Pushing Unknown Scene");
            break;
    } 

    [self setCurrentScene:kGameScene];
*/
}

-(void) popScene
{
    [[CCDirector sharedDirector] popScene];
}

#pragma mark - Start Specific Level
-(void) playLevel:(int)level
{
	self.currentLevel = level;
	
	//TODO: Start specific level
	PlayScene *scene = [PlayScene node];
	[[CCDirector sharedDirector] pushScene:scene];
}

#pragma mark - Next Level
-(void) nextLevel
{
	self.currentLevel++;
	
	//TODO: Jump to Next Level if necessary
}

@end
